#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
using u128 = __uint128_t; mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());
namespace LB
{
	u128 b[128];
	inline void clr() { fill(b, b + 128, 0); }
	inline bool ins(u128 x)
	{
		Fol(i, 127, 0) if ( x & ( (u128)1 << i ) )
			if ( b[i] ) x ^= b[i];
			else { b[i] = x; return true; }
		return false;
	}
};
int n, m, q, u, v; bool used[200009], tr[200009], ans; u128 h[200009]; vector < pair < int, int > > g[200009];
inline void dfs(int u, int fa = 0)
{
	used[u] = true;
	for ( auto _ : g[u] ) if ( _.second != fa && !used[_.first] ) tr[_.second] = true, dfs(_.first, _.second);
}
inline void dfs2(int u, int fa = 0)
{
	for ( auto _ : g[u] ) if ( _.second != fa )
	{
		if ( tr[_.second] ) dfs2(_.first, _.second);
		if ( fa ) h[fa] ^= h[_.second];
	}
}
int main()
{
	freopen("graph.in", "r", stdin), freopen("graph.out", "w", stdout);
	cin.tie(nullptr) -> sync_with_stdio(false);
	cin >> n >> m;
	For(i, 1, m) cin >> u >> v, g[u].emplace_back(v, i), g[v].emplace_back(u, i);
	dfs(1); For(i, 1, m) if ( !tr[i] ) h[i] = ( (u128)rnd() << 64 ) | rnd(); dfs2(1);
	for ( cin >> q ; q-- ; cout << ( ans ? "YES\n" : "NO\n" ) )
		for ( LB::clr(), ans = true, cin >> u ; u-- ; cin >> v, ans &= LB::ins(h[v]) );
	return 0;
}